<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2011 Florian Müller <it-admin@ifp-potsdam.co>, IFP
*  
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 3 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
 * Kurs
 */
class Tx_IfpCurriculum2_Domain_Model_Kurs extends Tx_Extbase_DomainObject_AbstractEntity {

	/**
	 * Version des Kurs
	 *
	 * @var integer
	 * @validate NotEmpty
	 */
	protected $version;

	/**
	 * Titel des Kurse
	 *
	 * @var string
	 */
	protected $titel;

	/**
	 * Unterrichtseinheiten
	 *
	 * @var integer
	 * @validate NotEmpty
	 */
	protected $ue;

	/**
	 * Beschreibung
	 *
	 * @var string
	 */
	protected $beschreibung;

	/**
	 * Litaraturvorschläge
	 *
	 * @var string
	 */
	protected $literatur;

	/**
	 * Dozent
	 *
	 * @var Tx_IfpCurriculum2_Domain_Model_Dozent
	 */
	protected $dozent;

	/**
	 * veranstaltungen
	 *
	 * @var Tx_Extbase_Persistence_ObjectStorage<Tx_IfpCurriculum2_Domain_Model_Veranstaltung>
	 * @lasy
	 */
	protected $veranstaltungen;

	/**
	 * Kursstamm
	 *
	 * @var Tx_IfpCurriculum2_Domain_Model_Kursstamm
	 * 
	 */
	protected $kursstamm;
	/**
	 * Inaktiv
	 *
	 * @var boolean
	 */
	protected $inaktiv;
	/**
	* TP/AP/..
	*
	* @var string
	*/
	protected $fachbereich;
	/**
	 *
	 * TP/AP/ÄWB/KPT/GrTh
	 * @var array
	 */
	
	
	protected $fachbereichDef=array(0=>'TP',1=>'AP',2=>'Ä PP',3=>'KPT',4=>'GrTH',5=>'Ä PF',6=>'Ä PS',7=>'Sys');


	public function __construct() {
		//Do not remove the next line: It would break the functionality
		$this->initStorageObjects();
	}

	/**
	 * Initializes all Tx_Extbase_Persistence_ObjectStorage instances.
	 *
	 * @return void
	 */
	protected function initStorageObjects() {
		/**
		* Do not modify this method!
		* It will be rewritten on each save in the kickstarter
		* You may modify the constructor of this class instead
		*/
		$this->veranstaltungen = new Tx_Extbase_Persistence_ObjectStorage();
	}

	/**
	 * @param integer $version
	 * @return void
	 */
	public function setVersion($version) {
		$this->version = $version;
	}

	/**
	 * @return integer
	 */
	public function getVersion() {
		/*if($this->version==0){
			return $this->getKursstamm()->getNextVersion();
		}*/
		return $this->version;
	}

	/**
	 * @param string $titel
	 * @return void
	 */
	public function setTitel($titel) {
		$this->titel = $titel;
	}

	/**
	 * @return string
	 */
	public function getTitel() {
		return $this->titel;
	}
	public function getTitelDetail(){
		return $this->kursstamm->getKursNr()."-".$this->version.": ".$this->titel;
	}
	public function getStammtitelDetail(){
		return $this->kursstamm->getKursNr()."-".$this->version.": ".$this->getStammtitel();
	}

	/**
	 * @param integer $ue
	 * @return void
	 */
	public function setUe($ue) {
		$this->ue = $ue;
	}

	/**
	 * @return integer
	 */
	public function getUe() {
		return $this->ue;
	}

	/**
	 * @param string $beschreibung
	 * @return void
	 */
	public function setBeschreibung($beschreibung) {
		$this->beschreibung = $beschreibung;
	}

	/**
	 * @return string
	 */
	public function getBeschreibung() {
		return $this->beschreibung;
	}

	/**
	 * @param string $literatur
	 * @return void
	 */
	public function setLiteratur($literatur) {
		$this->literatur = $literatur;
	}

	/**
	 * @return string
	 */
	public function getLiteratur() {
		return $this->literatur;
	}

	/**
	 * @param Tx_IfpCurriculum2_Domain_Model_Dozent $dozent
	 * @return void
	 */
	public function setDozent(Tx_IfpCurriculum2_Domain_Model_Dozent $dozent) {
		$this->dozent = $dozent;
	}

	/**
	 * @return Tx_IfpCurriculum2_Domain_Model_Dozent
	 */
	public function getDozent() {
		return $this->dozent;
	}

	/**
	 * @param Tx_Extbase_Persistence_ObjectStorage<Tx_IfpCurriculum2_Domain_Model_Veranstaltung> $veranstaltungen
	 * @return void
	 */
	public function setVeranstaltungen(Tx_Extbase_Persistence_ObjectStorage $veranstaltungen) {
		$this->veranstaltungen = $veranstaltungen;
	}

	/**
	 * @return Tx_Extbase_Persistence_ObjectStorage<Tx_IfpCurriculum2_Domain_Model_Veranstaltung>
	 */
	public function getVeranstaltungen() {
		return $this->veranstaltungen;
	}

	/**
	 * @param Tx_IfpCurriculum2_Domain_Model_Veranstaltung the Veranstaltung to be added
	 * @return void
	 */
	public function addVeranstaltungen(Tx_IfpCurriculum2_Domain_Model_Veranstaltung $veranstaltungen) {
		$this->veranstaltungen->attach($veranstaltungen);
	}

	/**
	 * @param Tx_IfpCurriculum2_Domain_Model_Veranstaltung the Veranstaltung to be removed
	 * @return void
	 */
	public function removeVeranstaltungen(Tx_IfpCurriculum2_Domain_Model_Veranstaltung $veranstaltungenToRemove) {
		$this->veranstaltungen->detach($veranstaltungenToRemove);
	}

	/**
	 * @param Tx_IfpCurriculum2_Domain_Model_Kursstamm $kursstamm
	 * @return void
	 */
	public function setKursstamm(Tx_IfpCurriculum2_Domain_Model_Kursstamm $kursstamm) {
		$this->kursstamm = $kursstamm;
	}

	/**
	 * @return Tx_IfpCurriculum2_Domain_Model_Kursstamm
	 */
	public function getKursstamm() {
		return $this->kursstamm;
	}
	/**
	 * 
	 * Enter description here ...
	 *  @return Tx_IfpCurriculum2_Domain_Model_Modul
	 */
	public function getModul(){
		return $this->kursstamm->getModul();
	}
	
	public function getKursNr(){
		return $this->kursstamm->getKursNr().".".$this->getVersion();
	}
	
	public function isInaktiv(){
		return $this->inaktiv;
	}
	/**
	 * 
	 * Enter description here ...
	 * @param boolean $inaktiv
	 */
	public function setInaktiv( $inaktiv){
		 $this->inaktiv=$inaktiv;
	}
	
/**
	 * 
	 * Enter description here ...
	 * @return Tx_IfpCurriculum2_Domain_Model_Semester
	 */
	public function getNextSemester(){
		return $this->getKursstamm()->getTurnuso()->getNextSemester();
		
	}
	/**
	 * Gibt den Kursstammtitel und wenn verfügbar den Kurstitel in der nächsten Zeile zurück
	 * @return string
	 */
	public function getStammtitel(){
		$str=$this->getKursstamm()->getTitel();
		if($this->getTitel())
			$str.=" -\n".$this->getTitel();
		return $str;
	}
	/**
	* @param string $type
	* @return void
	*/
	public function setFachbereich($fachbereich) {
		$this->fachbereich = $fachbereich;
	}
	
	/**
	 * @return string
	 */
	public function getFachbereich() {
		return $this->fachbereich;
	}
	/**
	*
	* Enter description here ...
	* @return string
	*/
	public function getFachbereichDef(){
		foreach ($this->fachbereichDef as $key =>$fachbreichCode) {
			if(strpos($this->fachbereich,strval($key)) !== false) {
				if($returnStr)
				$returnStr.=", ".$fachbreichCode;
				else
				$returnStr=$fachbreichCode;
			}
		}
		return $returnStr;
	}

}
?>